using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using NCS.Module.Multimedia.Library;
using NCS.Module.Multimedia.Library.Bonus;
using NCS.Module.Multimedia.Library.Gallery;
using NCS.Library.Utilities;
using NCS.Library;

namespace NCS.Module.Multimedia.Web.Bonus
{
    public partial class BonusGetTop : GalleryWebControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            int catid = ConvertUtility.ToInt32(Request.QueryString["catid"]);
            if (catid != 0)
            {
                Advertisement1.Param = "catid";
            }
            
            rptTrailer.DataSource = Gallery_BonusController.GetTopBonus(3, 0);
            rptTrailer.ItemDataBound += new RepeaterItemEventHandler(rptTrailer_ItemDataBound);
            rptTrailer.DataBind();

        }

        void rptTrailer_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemIndex < 0) return;
            DataRowView currow = (DataRowView)e.Item.DataItem;
            Image imgPic = (Image)e.Item.FindControl("imgPic");
            HyperLink hplTitle = (HyperLink)e.Item.FindControl("hplTitle");
            Literal litSummary = (Literal)e.Item.FindControl("litSummary");

            hplTitle.NavigateUrl = BuildUrlByBonusId(ConvertUtility.ToInt32(currow["BonusID"]));
            if (ConvertUtility.ToString(currow["BonusAvatar"]) != string.Empty)
            {
                imgPic.ImageUrl = MultimediaUtility.GetBonusAvatar(currow["BonusAvatar"].ToString());
                imgPic.Attributes.Add("onclick", "window.location='" + BuildUrlByBonusId(albumid) + "'");
                imgPic.Attributes.Add("style", "cursor:hand");
            }
            else
            {
                imgPic.Visible = false;
            }
            hplTitle.Text = ConvertUtility.ToString(currow["BonusName"]);
            litSummary.Text = ConvertUtility.ToStringWithoutFontBoldLength(currow["BonusDescription"], ConvertUtility.ToString(currow["BonusName"]).Length);
        }
      
        
    }
}